package com.ds.springboot.controller;

import com.ds.springboot.pojo.Department;
import com.ds.springboot.service.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @program: springboot-1-cache
 * @description:
 * @author: Dawson.Zhang
 * @create: 2020-05-20
 **/
@RestController
public class DeptController {

    @Autowired
    DeptService deptService;

    @GetMapping("/dept/{id}")
    public Department getById(@PathVariable("id") Integer id){
        Department byId = deptService.getById(id);
        return byId;
    }

    @PostMapping("/dept")
    public Department update(Department department){
        return deptService.update(department);
    }

    @PutMapping("/dept")
    public Department add(Department department){
        Department add = deptService.add(department);
        return add;
    }
    @DeleteMapping("/dept/{id}")
    public int del(@PathVariable("id") Integer id){
        return deptService.del(id);
    }
}
